#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void* thr1(void* arg)
{
        while (1){
                pthread_mutex_lock(&mutex);
                printf("hello world\n");
                pthread_mutex_unlock(&mutex);
                sleep(1);
        }
        return NULL;
}
static void* thr2(void* arg)
{
        while (1){
                pthread_mutex_lock(&mutex);
                printf("HELLO WORLD\n");
                pthread_mutex_unlock(&mutex);  
                sleep(1);    
        }
        return NULL;
}
int main(int argc, char const *argv[])
{
        pthread_t tid[2];
        pthread_attr_t attr;
        pthread_attr_init(&attr);
        pthread_create(&tid[1],&attr,thr1,NULL);
        pthread_create(&tid[2],&attr,thr2,NULL);
        pthread_attr_destroy(&attr);
        pthread_exit(NULL);
        return 0;
}